/**  
 * @Title: Rank_game.java
 * @Package com.limit.model
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-3-31 下午02:21:30
 * @version V1.0
 */ 
package com.limit.model;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

/** 
 * <br/>
 * @author maoyun(maoyun0903@163.com)
 * @date 2014-3-31 下午02:21:30 
 * @version V1.0
 */

public class RankGame extends Model<RankGame>{

	
	public static final RankGame dao = new RankGame();
	
	/**
	 * 根据主键game_id和rank_id查找唯一记录 
	 */
	public boolean findPrimaryRecord(long rank_id , long game_id){
		
		RankGame rankGame = RankGame.dao.findFirst("select * from rank_game where rank_id = ? and game_id = ?", rank_id , game_id);
		return rankGame == null ? false : true; 
		
	}

	/** 
	 * 根据主键 删除记录
	 */
	public boolean deleteByPrimary(long rank_id, long game_id) {
		int flag = Db.update("delete from rank_game where rank_id = ? and game_id = ?", rank_id , game_id);
		return flag > 0 ? true : false;
	}

	/** 
	 * 返回值类型为：int 若成功则返回更新记录的ID号
	 */
	public int updateByPrimary(long rank_id, long game_id ,int sort_id) {
		
		return Db.update("update rank_game set `sort_id` = ? where rank_id = ? and game_id =?",sort_id , rank_id ,game_id);
		
	}
	
}
